package com.geek.morning;

/**
 * @author SunBingJian
 * @desc TODO
 * @date 2025/9/2
 */
public class StringDemo {

    public static void main(String[] args) {
        //字符串常量池中
        String s1 = "12";
        String s2 = "12";
        System.out.println(s1 == s2);      //比较地址  true
        System.out.println(s1.equals(s2)); //比较内容  true

        //new创建对象
        String s3 = new String("12");
        String s4 = new String("12");
        System.out.println(s3 == s4);      //比较地址  false
        System.out.println(s3.equals(s4)); //比较内容  true

        System.out.println(s3 == s1);      //比较地址  false
        System.out.println(s3.equals(s1)); //比较内容  true
    }

}
